package com.example.leetcode.tree;


import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * AC
 */
class Solution105 {

    public TreeNode buildTree(int[] preorder, int[] inorder) {
        return TreeUtils.buildTreeByPreAndInOrder(preorder, 0, preorder.length - 1, inorder, 0, inorder.length - 1);
    }

}

/**
 * 105. 从前序与中序遍历序列构造二叉树
 */
public class leetcode105 {

    public static void main(String[] args) {

        int[] preorder = {3,9,20,15,7};
        int[] inorder = {9,3,15,20,7};

//        int[] preorder = {1, 2};
//        int[] inorder = {2, 1};

        Solution105 solution105 = new Solution105();

        TreeNode root = solution105.buildTree(preorder, inorder);

        TreeUtils.treeBFSTraverseWithLevelInfo(root);

    }
}
